"use server";
import Image from "next/image";
import { Button, Flex, message } from "antd";
import React from "react";
import Link from "next/link";
import Title from "antd/es/typography/Title";
import { listQuestionBankVoByPageUsingPost } from "@/api/questionBankController";
import QuestionBankList from "@/components/QuestionBankList";

export default async function HomePage() {
  let questionBankList: string[] | undefined = [];
  try {
    const res = await listQuestionBankVoByPageUsingPost({
      pageSize: 20,
      sortField: "createTime",
      sortOrder: "descend",
    });
    questionBankList = res.data.records ?? [];
  } catch (e) {
    message.error("获取题库失败");
  }
  return (
    <div id="bankPage" className="max-width-content">
      <Flex justify="space-between" align={"center"}>
        <Title level={3}>最新题库</Title>
      </Flex>
      <QuestionBankList questionBankList={questionBankList} />
    </div>
  );
}
